package com.ruoyi.equ.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.equ.domain.EquColReruReport;
import com.ruoyi.equ.service.IEquColrerureportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 设备基本信息Controller
 * 
 * @author ruoyi
 * @date 2024-03-29
 */
@RestController
@RequestMapping("/equ/colrerureport")
public class EquColrerureportController extends BaseController
{
    @Autowired
    private IEquColrerureportService equColrerureportService;

    /**
     * 查询设备基本信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(EquColReruReport equColrerureport)
    {
        startPage();
        List<EquColReruReport> list = equColrerureportService.selectEquColrerureportList(equColrerureport);
        return getDataTable(list);
    }

    /**
     * 导出设备基本信息列表
     */
    @Log(title = "设备基本信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EquColReruReport equColrerureport)
    {
        List<EquColReruReport> list = equColrerureportService.selectEquColrerureportList(equColrerureport);
        ExcelUtil<EquColReruReport> util = new ExcelUtil<EquColReruReport>(EquColReruReport.class);
        util.exportExcel(response, list, "设备基本信息数据");
    }

    /**
     * 获取设备基本信息详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(equColrerureportService.selectEquColrerureportById(id));
    }

    /**
     * 新增设备基本信息
     */
    @Log(title = "设备基本信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EquColReruReport equColrerureport)
    {
        return toAjax(equColrerureportService.insertEquColrerureport(equColrerureport));
    }

    /**
     * 修改设备基本信息
     */
    @Log(title = "设备基本信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EquColReruReport equColrerureport)
    {
        return toAjax(equColrerureportService.updateEquColrerureport(equColrerureport));
    }

    /**
     * 删除设备基本信息
     */
    @Log(title = "设备基本信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(equColrerureportService.deleteEquColrerureportByIds(ids));
    }
}
